package com.gagakuai.bpm.config.security;

import com.gagakuai.bpm.rpcservice.openfeign.UserHttpApi;
import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class UpdateSecurityRisks implements JavaDelegate {

    @Resource
    private UserHttpApi userHttpApi;

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        try{
            log.info("execution:{}，{}", execution.getVariables(), execution.getBusinessKey());
            // 回调业务接口（复制数据）
//            if(StringUtils.isNotEmpty(execution.getBusinessKey())){
//                ResponseStatusDto<Void> responseStatusDto = userHttpApi.UpdateSecurityRisks(execution.getBusinessKey());
//                log.info("回调结果为：{}", String.join(":",
//                        responseStatusDto.getStatus(),
//                        responseStatusDto.getMessage(),
//                        responseStatusDto.getCode()));
//            }
        }catch (Exception e){
            throw new Exception("调用更新安全隐患库接口异常 ", e);
        }
    }
}
